SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE FUNCTION [dbo].[fnLoginCheck]
(
@Username nvarchar(50),
@Password nvarchar(MAX)
)
RETURNS INT
AS
BEGIN
	IF (select COUNT(Id) from Member where UserName = @Username) = 0
		RETURN 1;
	ELSE IF (select COUNT(Id) from Member where UserName = @Username and Password = @Password) = 0
		RETURN 2;
	ELSE IF (select COUNT(Id) from Member where UserName = @Username and Password = @Password and IsActive = 1) = 0
		RETURN 3;
	ELSE
		RETURN 4;
RETURN 5;
END
GO
